package com.ldg.crm.dao;

import com.ldg.crm.entity.BaseEntity;
import com.ldg.crm.entity.BaseEntityExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface BaseDao {
    /**
     *
     * @mbg.generated
     */
    @SelectProvider(type=BaseEntitySqlProvider.class, method="countByExample")
    long countByExample(BaseEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @DeleteProvider(type=BaseEntitySqlProvider.class, method="deleteByExample")
    int deleteByExample(BaseEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @Delete({
        "delete from crm_base",
        "where base_id = #{baseId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer baseId);

    /**
     *
     * @mbg.generated
     */
    @Insert({
        "insert into crm_base (base_id, name, ",
        "adders, phone)",
        "values (#{baseId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
        "#{adders,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="baseId", before=true, resultType=Integer.class)
    int insert(BaseEntity record);

    /**
     *
     * @mbg.generated
     */
    @InsertProvider(type=BaseEntitySqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="baseId", before=true, resultType=Integer.class)
    int insertSelective(BaseEntity record);

    /**
     *
     * @mbg.generated
     */
    @SelectProvider(type=BaseEntitySqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="base_id", property="baseId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="adders", property="adders", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR)
    })
    List<BaseEntity> selectByExample(BaseEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @Select({
        "select",
        "base_id, name, adders, phone",
        "from crm_base",
        "where base_id = #{baseId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="base_id", property="baseId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="adders", property="adders", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR)
    })
    BaseEntity selectByPrimaryKey(Integer baseId);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=BaseEntitySqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") BaseEntity record, @Param("example") BaseEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=BaseEntitySqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") BaseEntity record, @Param("example") BaseEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=BaseEntitySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(BaseEntity record);

    /**
     *
     * @mbg.generated
     */
    @Update({
        "update crm_base",
        "set name = #{name,jdbcType=VARCHAR},",
          "adders = #{adders,jdbcType=VARCHAR},",
          "phone = #{phone,jdbcType=VARCHAR}",
        "where base_id = #{baseId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(BaseEntity record);
}